﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace startjar
{
    class Program
    {
        static void Main(string[] args)
        {
            string pythonFilePath = Directory.GetCurrentDirectory() + "\\脚本\\自动出报告\\WriteHtml_地图.py";
            Process proc = null;
            try {
                proc = new Process();
                //proc.StartInfo.WorkingDirectory = pythonFilePath;
                proc.StartInfo.FileName = @"C:\Windows\System32\cmd.exe";
                proc.StartInfo.RedirectStandardInput = true;   //接受来自调用程序的输入信息
                proc.StartInfo.RedirectStandardOutput = true;  //由调用程序获取输出信息
                proc.StartInfo.UseShellExecute = false;       //要重定向 IO 流，Process 对象必须将 UseShellExecute 属性设置为 False
                proc.StartInfo.CreateNoWindow = true;          //不显示程序窗口
                proc.Start();

                string cmd = "java -jar remoteservice.jar &exit";
                
                proc.StandardInput.WriteLine(cmd);
                proc.StandardInput.AutoFlush = true;
                //获取cmd窗口的输出信息
                string output = proc.StandardOutput.ReadToEnd();
                proc.WaitForExit();
                proc.Close();
            } catch (Exception ex) {
                Console.WriteLine("Exception Occurred :{0},{1}", ex.Message, ex.StackTrace.ToString());
            }

        }
    }
}
